import os
import base64
import string
import random


# 拼接图片路径
def get_image_path(filename):
    return os.path.join('image', filename)


# 图片 base64 编码
def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")


def gen_filename(length=15):
    letters = string.ascii_letters
    return ''.join(random.choice(letters) for _ in range(length))
